#include <iostream>

using namespace std;

class target {
public:
    target() {
        cout << "target::target()" << endl;
    }
    ~target() {
        cout << "target::~target()" << endl;
    }
    virtual void request() = 0;
};

class adaptee {
public:
    adaptee() {
        cout << "adaptee::adaptee()" << endl;
    }
    ~adaptee() {
        cout << "adaptee::~adaptee()" << endl;
    }
    void specialRequest() {
        cout << "specialRequest" << endl;
    }
};

class adapter: public target {
private:
    adaptee* m_adaptee;
public:
    adapter(adaptee* a) {
        this->m_adaptee = a;
    }
    ~adapter() {
        cout << "adapter::~adapter() called" << endl;
        if (m_adaptee) {
            delete m_adaptee;
        }
    }
    void request() {
        m_adaptee->specialRequest();
    }
};

int main(int argc, char** argv) {
    target* t = new adapter(new adaptee());
    t->request();
    delete t;
}
